#!/bin/bash

#

# xargs usage
#pidof DaemonExe |xargs -i cat /proc/{}/statm 
cmd=`pidof RTDaemonExe`
echo "pidof RTDaemonExe $cmd"
echo "pidof DaemonExe `pidof DaemonExe`"

page_size=`getconf PAGESIZE` #4096



memory=`free -m | grep Mem`
read total used buffers cached <<< `echo "$memory" |awk '{print $2,$3,$6,$7}'`
echo "total:$total used:$used buffers:$buffers cached:$cached"

rss=`cat /proc/$(pidof DaemonExe)/status |grep VmRSS|awk '{print $2}'`
#share=`cat /proc/$(pidof DaemonExe)/statm |awk '{print $3}'`

read a b  <<< `cat /proc/$(pidof DaemonExe)/statm |awk '{print $2,$3}'`
uss=$(($a-$b))
echo "page_size $page_size  rss $rss share $share uss $uss"

while true; do read a b  <<< `cat /proc/$(pidof CCSRTDaemonExe)/statm |awk '{print $2,$3}'`;echo "uss $(($a-$b))"; sleep 2; done


#while true; do pidof CCSDaemonExe|xargs -i pmap -x {}| tail -1; sleep 1; done

while true; do pmap -x `pidof CCSDaemonExe`| tail -1; sleep 1; done

## [文件分割](https://www.cnblogs.com/OliverQin/p/10240222.html) 
split -b 1000k tmp.log
split -l 10000 tmp.log -d -a 2 row_

split -b 30m CUST_INFO.dat -d -a 2 file_&&ls|grep file_|xargs -n1 -i{} mv {} {}.txt


readelf -s Binary|grep UND|grep -v GLIBC|awk '{print $8}'|sort -n|uniq


for dir in `ls `
do
   echo $dir
   cd $dir/;git reset HEAD --hard ;cd -
done


if [ -d "Test" ]; then 
	echo "$dir is a dir"
else
	echo "$dir is a file"
fi

if [ $1x == "ab"x ]; then
    echo "you had enter ab"
elif [ $1x == "cd"x ]; then
    echo "you had enter cd"
else
    echo "you had enter unexpected word"
fi

# 前100个占用内存总和
ps -aux | sort -k6nr | head -n 100 | awk '{sum+=$6} END {print sum}'